<?php
/**
 * Created by PhpStorm.
 * User: giozola
 * Date: 2018/9/29
 * Time: 9:31
 */

namespace addons\hlapp\model;


class HlappEvaluateSendLogs extends CommonModel
{
    public function getTypeAttr($value){
        $type=array(null=>'未知',1=>"评价推送",2=>"方案推送");
        return $type[$value];
    }
    //状态获取器
    public function getStatusAttr($value){
        $status=array(0=>'失败',1=>'成功');
        return $status[$value];
    }

    public function project(){
        return $this->hasOne('HlappProject','id','projectId');
    }
    //人员
    public function memberInfo(){
        return $this->hasOne('HlappMember','id','member');
    }

    // 获取失败日志
    //type 类型，1 评价推送，2 方案推送
    // hours  时间 小时数内的失败日志信息
    public function getFalseLog($type,$time){
        $that = $this->with('project,memberInfo')->where('status',0);
        if ($time){
            $that = $that->where('create_time','>',$time);
        }
        $errlog = $that
            ->where('type',$type)
            ->order('id','desc')
            ->select();
        return $errlog;
    }
}